package com.common.util;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Date;
import java.util.UUID;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;



public class FileImages
{
	/**
	 * @功能: 图片处理
	 * @日期: May 22, 20124:43:00 PM
	 * @作者: 蒋文书
	 */
	public static void fileImages(String fileImages) throws Exception {
		String dateFolder = DateUtils.toString(new Date(), "yyyy-MM-dd").replace("-", "/");
		String path=ServletActionContext.getServletContext().getRealPath("UserFiles") + "/" + dateFolder;
		File file = new File(path+"/"+fileImages);
		File parent = file.getParentFile();
		FileUtils.copyFile(new File(fileImages), file);
		if (parent != null && !parent.exists()) {
			parent.mkdirs();
		}		
			file.createNewFile();

	}


}
